export default {
  data() {
    return {
      panelActive: true,
      pageSizeOptions: [5, 10, 20, 30, 40, 50, 80, 100, 120, 150, 200],
      pagination: {
        pageNum: 1,
        pageSize: 10
      },
      loading: false,
      dataList: [],
      total: 0,
      selectedDataList: [],
      searchModel: {},
      sort: {},
      addDialogObj: {
        isVisible: false,
        title: ""
      },
      detailDialogObj: {
        isVisible: false,
        title: ""
      },
      params: {},
      maxHeightDialog: this.getHeightAndWidth()
    };
  },
  created() {},
  methods: {
    getHeightAndWidth() {
      let clientHeight = 0;
      if (
        document.body.scrollHeight === window.screen.height &&
        document.body.scrollWidth === window.screen.width
      ) {
        clientHeight = window.screen.height - 5; // 网页可见区域高
      } else {
        clientHeight = document.body.clientHeight - 5; // 网页可见区域高
      }
      return clientHeight - 220 + "px";
    },
    formatSearchData(search) {
      const searchModel = {};
      for (const key in search) {
        searchModel[key] = search[key] == null ? "" : search[key];
        if (typeof searchModel[key] === "string") {
          searchModel[key] = searchModel[key]
            .replace(/^(\s|\u00A0)+/, "")
            .replace(/(\s|\u00A0)+$/, "");
        }
      }
      return searchModel;
    },
    formatIndex(index, pagination) {
      return index + 1 + (pagination.pageNum - 1) * pagination.pageSize;
    },
    dialogClose(key) {
      this[key].isVisible = false;
    }
  }
};
